const db = require('../../db/sql')

function deleteDepartment(params,res){
    // 删除指定id对应数据的SQL语句
    let deleteSql = 'DELETE FROM department WHERE id = ?';
// 定义要删除的id
    const idToDelete = params.id;
    console.log(params,'要删除的id')

        // 执行删除操作
        db.query(deleteSql, [idToDelete], function(error, results, fields) {

            if (error) {
                console.log(error)
                res.status(506).send({
                    msg:'服务器错误,修改失败'
                })
                throw error;
            }
            console.log(`Deleted ${results.affectedRows} rows`);
            res.status(200).send({
                msg:'删除成功'
            })
        });

}
module.exports =deleteDepartment
